<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * CodeIgniter Application Controller Class
 *
 * This class object is the super class that every library in
 * CodeIgniter will be assigned to.
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @category	Libraries
 * @author		ExpressionEngine Dev Team
 * @link		http://codeigniter.com/user_guide/general/controllers.html
 */
class CI_Controller {

	private static $instance;

	/**
	 * Constructor
	 */
	public function __construct()
	{
		self::$instance =& $this;

		foreach (is_loaded() as $var => $class)
		{
			$this->$var =& load_class($class);
		}

		$this->load =& load_class('Loader', 'core');

		$this->load->initialize();
		
		log_message('debug', "Controller Class Initialized");
	}

	public static function &get_instance()
	{
		return self::$instance;
	}

	public function init($title=null,$js=null,$css=null) {
		$CI = & get_instance();
		$html = array();
		$header['title'] = $title;
		$header['js']=$this->str2array($js);
		$header['css']=$this->str2array($css);
		$menu=array();
		$header['menu']=$CI->load->view("menu", $menu, true);
		$html['header']=$CI->load->view("header", $header, true);
		$html['left']="";
		$footer=array();
		$html['footer']=$CI->load->view("footer", $footer, true);
		return $html;
	}

	public function load_js($jsFile,$path=null){   
		
	}
	public function load_css($cssFile,$path=null){   
		
	}
	/**
     * 将字符串转换为数组，并反向键值关系
     * @param string $str
     */
    private function str2array($str)
    {
        $ret = explode(',', $str);
        return array_flip($ret);
    }
}
// END Controller class

/* End of file Controller.php */
/* Location: ./system/core/Controller.php */